package com.chen.rabbit;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.xml.crypto.Data;
import java.util.Date;

/**
 * @decription:创建消息生产者
 * @atuhor:陈红卫
 * @create : 2017-06-20-10:07
 */
@Component
public class Sender {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send(){
        String context ="hello" +new Date();

        System.out.println("Sender:"+context);

        /*
        *  将消息发送到hello的队列中
        * */
        this.rabbitTemplate.convertAndSend("hello",context);
    }
}
